import React, { Component } from 'react'
import styles from "./index.less"
import FixBig from "@/components/FixBg"
import BigBox from "@/components/BigBox"


export default class test extends Component {
  constructor(props) {
    super(props)

    this.state = {
      src: ""
    }
  }

  componentDidMount() {
    const that = this;
    var body = document.getElementsByTagName('body')[0];
    body.addEventListener('paste', function (e) {
      var clipboard = e.clipboardData;
      var type = clipboard.items[0].type;
      if (type.match(/image/)) {
        var blob = clipboard.items[0].getAsFile();
        var file = new FileReader();
        file.addEventListener('loadend', function (e) {
          that.setState({
            src:e.target.result
          })
          // console.log(e.target.result)
        });
        file.readAsDataURL(blob);
      } else {
        console.log("not an image\ntype: " + type)
      }
    });
  }
  render() {
    return (
      <div className={styles.block} >
        {/* <FixBig src={"/bg1.jpg"}
          overLayerStyle={
            { backgroundColor: "rgba(255, 255, 255, .8)" }
          }
        /> */}
        {/* <BigBox width={800} height={600} isOldSize={false}>
         
        </BigBox> */}
        <img src={this.state.src} alt=""/>
      </div>
    )
  }
}
